from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
# 导入 Service 类（关键）
from selenium.webdriver.chrome.service import Service

#实例化对象：

service = Service(executable_path="E:\\python\\python38\\chromedriver.exe")
driver = webdriver.Chrome(service=service)
url = r"C:\Users\alg\PycharmProjects\UI自动化\注册实例.html"
driver.get(url)
action = ActionChains(driver)
driver.maximize_window()
sleep(5)

#填写主页面注册信息
driver.find_element(By.CSS_SELECTOR,"#user").send_keys("admin")
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
driver.find_element(By.CSS_SELECTOR,"#tel").send_keys("130888888888")
driver.find_element(By.CSS_SELECTOR,"#email").send_keys("123@qq.com")

sleep(2)
#切换a页码进行注册
driver.switch_to.frame("idframe1")
#切换a页码注册
driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("6666")
driver.find_element(By.CSS_SELECTOR,"#passwordA").send_keys("123456")
driver.find_element(By.CSS_SELECTOR,"#telA").send_keys("130888888888")
driver.find_element(By.CSS_SELECTOR,"#emailA").send_keys("123@qq.com")

sleep(2)

# 3. 调用恢复默认页面方法(switch_to.default_content())
driver.switch_to.default_content()
# 4. 调用frame切换方法(switch_to.frame("myframe2"))切换到注册用户B框架中
#切换到注册B页面 使用name
driver.switch_to.frame("myframe2")
# 2). 填写注册页面B中的注册信息
driver.find_element(By.CSS_SELECTOR,"#userB").send_keys("6666")
driver.find_element(By.CSS_SELECTOR,"#passwordB").send_keys("123456")
driver.find_element(By.CSS_SELECTOR,"#telB").send_keys("130888888888")
driver.find_element(By.CSS_SELECTOR,"#emailB").send_keys("123@qq.com")
